package com.neutech.neusys.controller;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.neutech.neusys.service.DepartmentService;
import com.neutech.neusys.vo.ToAddDeartmentVo;
import com.neutech.po.Department;

@RestController
@RequestMapping("/neusys/department")
public class DepartmentController {
	@Autowired
	private DepartmentService departmentService;
	/**
	 * 添加科室
	 * @param：department 科室信息
	 * @return：添加成功还是失败："success"--成功,"error"--失败
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	public String addNewDepartment(Department department) {
		int result = departmentService.addDepartment(department);
		 if(result==1) {
			 return "success"; 
		 }else { 
			 return "error"; 
		 }
	}
	@RequestMapping(value="/toadd")
	public ToAddDeartmentVo todeartment(){
		return  departmentService.toAddConstantitem();
	}
	@RequestMapping(value="/queryAlldept",method=RequestMethod.GET)
	public List<Department> queryAllDept(){
		return departmentService.queryAllDept();
	}
	@RequestMapping(value="/update",method=RequestMethod.GET)
	public String getDepartment(Department department) {
		System.out.println(department.getId());
		System.err.println(department.getDeptCode());
		System.out.println(department.getDeptName());
		return "success";
	}
}
